package com.atguigu.blog.user.service.impl;

import com.atguigu.blog.user.entity.Article;
import com.atguigu.blog.user.feign.ArticleFeignClient;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.atguigu.blog.user.entity.User;
import com.atguigu.blog.user.service.UserService;
import com.atguigu.blog.user.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author Lenovo
* @description 针对表【users】的数据库操作Service实现
* @createDate 2024-12-25 14:59:58
*/
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User>
    implements UserService{

    @Autowired
    private ArticleFeignClient articleFeignClient;

    @Override
    public User findUserArticleList(Long id) {
       //获取用户信息
        User user =getById(id);
        if (user == null){
            return null;
        }
        //获取用户下的文章信息
        List<Article> articleList = articleFeignClient.queryArticleList(user.getUserId());
        user.setArticlesList(articleList);
        return user;
    }
}




